package com.abc.studentmanager.service.Impl;

import com.abc.studentmanager.domain.Route;
import com.abc.studentmanager.mapper.RouteMapper;
import com.abc.studentmanager.service.RouteService;
import com.abc.studentmanager.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Classname
 * @Description
 * @Created
 */
@Service
public class RouteServiceImpl implements RouteService {

    @Autowired
    private RouteMapper routeMapper;

    @Override
    public PageBean<Route> queryPage(Map<String, Object> paramMap) {
        PageBean<Route> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Route> datas = routeMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = routeMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public boolean isRoute(Route route) {
        Route at = routeMapper.isRoute(route);
        if(at != null){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public int addRoute(Route route) {
        return routeMapper.addRoute(route);
    }

    @Override
    public int deleteRoute(Integer id) {
        return routeMapper.deleteRoute(id);
    }
}
